// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store' //vuex框架
import {Modal, Message} from 'iView';//全局轻量化组件

//前端请求框架
var Fly = require("flyio/dist/npm/fly");
var fly = new Fly;

Vue.config.productionTip = false
Vue.prototype.$http = fly; //ajax框架挂载
Vue.prototype.$Modal = Modal; //全局模态框挂载
Vue.prototype.$Message = Message; //全局信息提示框挂载
//title修改
Vue.directive('title', {
  inserted: function (el, binding) {
      document.title = el.dataset.title
  }
});
//补0函数
function addZero(num) {
  let str = '';
  let mid = ''
  if (num < 10) {
      mid = "" + num;
      str = "0" + num;
  } else {
      str = mid + num;
  }
  ;
  return str
}
//倒计时（接口信息不全导致不安全，仅用于显示效果，接口不全后请重写）！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！*******重要
Vue.prototype.$InitTime = function InitTime(endtime) {

  var rightTime = (parseInt(endtime) * 1000) - new Date().getTime();

  if (rightTime <= 0) {
      return '结束'
  } else {
      var dd = Math.floor(rightTime / 1000 / 60 / 60 / 24);
      //console.log(Math.floor((rightTime / 1000 / 60) % 60));
      var hh = addZero(Math.floor(rightTime / 1000 / 60 / 60));
      var mm = addZero(Math.floor((rightTime / 1000 / 60) % 60));
      var ss = addZero(Math.floor((rightTime / 1000) % 60));
  }
  var arr = "" + hh + ":" + mm + ":" + ss;
  return arr;

};
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
